package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.pojo.Receipt_Transfer;
import com.gxa.service.TransferOrderService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Controller
@Api(value = "调拨单数据test",tags = "调拨单数据接口API")
public class TransferOrderController {
    R r = new R();
    @Autowired(required = false)
    private TransferOrderService transferOrderService;

    @RequestMapping(value = "/saveOrderForm",method = RequestMethod.POST)
    @ApiOperation(value = "新增调拨单接口",notes = "添加调拨单",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=401,message="仓库名不能相同"),
            @ApiResponse(code=402,message="库存不足"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R saveOrderForm(@RequestBody @ApiParam Receipt_Transfer receipt_transfer) {
       R r = transferOrderService.saveOrderForm(receipt_transfer);
       return r;
    }

    @RequestMapping(value = "/queryOrderForm",method = RequestMethod.POST)
    @ApiOperation(value = "查询调拨单接口",notes = "查询调拨单",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryOrderForm(@RequestBody @ApiParam(name = "map",value = "用户名和密码",required = true) Map map) {
        R r = transferOrderService.queryTransferOrder(map);
        System.out.println(map);
        return r;
    }

    @RequestMapping(value = "/delTransferOrder",method = RequestMethod.POST)
    @ApiOperation(value = "删除接口",notes = "删除", httpMethod = "POST", response = R.class)
    @ApiImplicitParam(name = "transferOrderId",value = "删除",required = false,paramType = "query",dataType = "String")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public  R  delTransferOrder(@RequestBody @ApiParam(name = "map",value = "用户名和密码",required = true) Map map){
        R r = transferOrderService.delTransferOrder(map);
        return  r;
    }

    @RequestMapping(value = "/auditTransferOrder",method = RequestMethod.POST)
    @ApiOperation(value = "审核调货单接口",notes = "审核购货单", response = R.class)
    @ResponseBody
    @ApiImplicitParam(name = "transferAudit",value = "审核码",required = false,paramType = "query",dataType = "String")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public  R  audit(@RequestBody Map map){
        R r = transferOrderService.autitTransferOrder(map);
        return  r;
    }

}
